package com.headingdata.arraylist;

import java.util.ArrayList;
import java.util.Scanner;

public class FoodOperator {

    ArrayList<Food> foods = new ArrayList<>();

    public void addFood(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入菜品名称：");
        String name = scanner.next();
        System.out.println("请输入菜品价格(元)：");
        double price = scanner.nextDouble();
        System.out.println("请输入菜品评分：");
        double score = scanner.nextDouble();
        System.out.println("请输入菜品描述：");
        String desc = scanner.next();
        Food food = new Food(name,price,score,desc);
        foods.add(food);
        System.out.println(food.getName()+"菜品上架成功!");
    }

    public void showAllFoods(){
        if(foods.size()==0){
            System.out.println("目前没有任何菜品上架！请先上架菜品！");
        }
        for (int i = 0; i < foods.size(); i++) {
            Food food = foods.get(i);
            System.out.println(food.getName());
            System.out.println(food.getPrice());
            System.out.println(food.getScore());
            System.out.println(food.getDescription());
            System.out.println("---------------------------------------------");
        }
    }

    public void selectOperation(){

        Scanner scanner = new Scanner(System.in);
        System.out.println("操作选择：\n 1.菜品上架\n 2.展示所有菜品\n 3.退出系统");
        System.out.println("请输入您的选择操作：");
        while (true) {
            int selectNum = scanner.nextInt();
            switch (selectNum){
                case 1:addFood();break;
                case 2:showAllFoods();break;
                case 3:
                    System.out.println("系统结束，下次再来哦！");
                    return;
                default:
                    System.out.println("您输入的命令不存在，请重新输入！");
                    break;
            }
        }


    }


}
